From: Simon McVittie Date: Thu, 25 Sep 2025 13:01:25 +0000 (+0800) Subject: vulkan: Optionally share one JSON manifest per driver between architectures X-Git-Tag: archive/raspbian/25.3.3-1+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f4d5d8d4ca47d9c1317be58e360b9e18d99bcc5e;p=mesa.git vulkan: Optionally share one JSON manifest per driver between architectures If the library_path is just a basename like `libvulkan_lvp.so`, then we can share the same JSON manifest like `lvp_icd.json` between all of the architectures, like we already do for Vulkan layers. The library will be looked up in the dynamic linker's default search path in this case, and in practice will be found in `${libdir}`. This is how the Mesa's EGL driver and Vulkan layers work, how Mesa is packaged in Debian 13, and also how the Nvidia proprietary driver works; it makes installation simpler for distros, especially on multiarch systems like Debian and the freedesktop.org SDK. However, if we want a separate manifest per architecture in order to be able to write the full path into it, we still need per-architecture filename disambiguation like `lvp_icd.x86_64.json`. We presumably still want a separate per architecture on Windows, because the concept of a single monolithic `${libdir}` is less common there, and it can also be helpful during development when setting `$VK_DRIVER_FILES` to force the use of a specific driver installed in a non-default location. Use the following parameter to passed to vk_icd_gen: '--icd-lib-path', vulkan_icd_lib_path, '--icd-filename', icd_file_name, output : 'virtio_icd.' + vulkan_manifest_suffix, and the output is passed by '--out', '@OUTPUT@', so we can detect vulkan_manifest_per_architecture from the --out parameter in script. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13745 Signed-off-by: Simon McVittie Co-authored-by: Yonggang Luo Reviewed-by: Mel Henning Reviewed-by: Matt Turner Reviewed-by: Eric Engestrom Part-of: Applied-upstream: 26.0, commit:b860ae309a42dce317d275000016abc2b4ebe687 Gbp-Pq: Name vulkan-Optionally-share-one-JSON-manifest-per-driver-betw.patch --- diff --git a/meson.build b/meson.build index f85cd266e..4bf16762a 100644 --- a/meson.build +++ b/meson.build @@ -2280,6 +2280,13 @@ else vulkan_icd_lib_path = get_option('prefix') / get_option('libdir') endif +vulkan_manifest_per_architecture = get_option('vulkan-manifest-per-architecture') + +if vulkan_manifest_per_architecture + vulkan_manifest_suffix = '@0@.json'.format(host_machine.cpu()) +else + vulkan_manifest_suffix = 'json' +endif subdir('include') subdir('bin') diff --git a/meson.options b/meson.options index b1f98d745..43c58236f 100644 --- a/meson.options +++ b/meson.options @@ -286,6 +286,19 @@ option( 'Default: $datadir/vulkan/icd.d' ) +option( + 'vulkan-manifest-per-architecture', + type : 'boolean', + value : true, + description : 'If true, Vulkan ICDs have a separate JSON manifest per ' + + 'architecture, for example lvp_icd.x86_64.json. ' + + '(Recommended for non-default ${prefix}.) ' + + 'If false, all architectures share a single JSON manifest, ' + + 'for example lvp_icd.json, referencing the library by its ' + + 'basename. ' + + '(Recommended for Unix OS distros installing into /usr.)' +) + option( 'moltenvk-dir', type : 'string', diff --git a/src/amd/vulkan/meson.build b/src/amd/vulkan/meson.build index 78b19aaa7..d73e6d525 100644 --- a/src/amd/vulkan/meson.build +++ b/src/amd/vulkan/meson.build @@ -289,7 +289,8 @@ icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] if with_platform_windows @@ -299,7 +300,7 @@ endif radeon_icd = custom_target( 'radeon_icd', input : [vk_icd_gen, vk_api_xml], - output : 'radeon_icd.@0@.json'.format(host_machine.cpu()), + output : 'radeon_icd.' + vulkan_manifest_suffix, command : icd_command, build_by_default : true, install_dir : with_vulkan_icd_dir, @@ -316,7 +317,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/asahi/vulkan/meson.build b/src/asahi/vulkan/meson.build index 820ee2dc2..a5e483cbc 100644 --- a/src/asahi/vulkan/meson.build +++ b/src/asahi/vulkan/meson.build @@ -106,12 +106,13 @@ icd_file_name = libname_prefix + 'vulkan_asahi.' + libname_suffix asahi_icd = custom_target( input : [vk_icd_gen, vk_api_xml], - output : 'asahi_icd.@0@.json'.format(host_machine.cpu()), + output : 'asahi_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -128,7 +129,8 @@ custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/broadcom/vulkan/meson.build b/src/broadcom/vulkan/meson.build index 42c1e351e..d5cdbcd1a 100644 --- a/src/broadcom/vulkan/meson.build +++ b/src/broadcom/vulkan/meson.build @@ -127,12 +127,13 @@ icd_file_name = libname_prefix + 'vulkan_broadcom.' + libname_suffix broadcom_icd = custom_target( 'broadcom_icd', input : [vk_icd_gen, vk_api_xml], - output : 'broadcom_icd.@0@.json'.format(host_machine.cpu()), + output : 'broadcom_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -150,7 +151,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/freedreno/vulkan/meson.build b/src/freedreno/vulkan/meson.build index 18e6aba13..c530d6ae8 100644 --- a/src/freedreno/vulkan/meson.build +++ b/src/freedreno/vulkan/meson.build @@ -202,12 +202,13 @@ icd_file_name = libname_prefix + 'vulkan_freedreno.' + libname_suffix freedreno_icd = custom_target( 'freedreno_icd', input : [vk_icd_gen, vk_api_xml], - output : 'freedreno_icd.@0@.json'.format(host_machine.cpu()), + output : 'freedreno_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -225,7 +226,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/gallium/targets/lavapipe/meson.build b/src/gallium/targets/lavapipe/meson.build index b79e3a4ca..d1d4e5ba2 100644 --- a/src/gallium/targets/lavapipe/meson.build +++ b/src/gallium/targets/lavapipe/meson.build @@ -24,7 +24,8 @@ icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] if host_machine.system() == 'windows' @@ -34,7 +35,7 @@ endif lvp_icd = custom_target( 'lvp_icd', input : [vk_icd_gen, vk_api_xml], - output : 'lvp_icd.@0@.json'.format(host_machine.cpu()), + output : 'lvp_icd.' + vulkan_manifest_suffix, command : icd_command, build_by_default : true, install_dir : with_vulkan_icd_dir, @@ -51,7 +52,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/gfxstream/guest/vulkan/meson.build b/src/gfxstream/guest/vulkan/meson.build index b00d5e39a..004606f51 100644 --- a/src/gfxstream/guest/vulkan/meson.build +++ b/src/gfxstream/guest/vulkan/meson.build @@ -49,12 +49,13 @@ icd_file_name = libname_prefix + 'vulkan_gfxstream.' + libname_suffix gfxstream_icd = custom_target( 'gfxstream_vk_icd', input : [vk_icd_gen, vk_api_xml], - output : 'gfxstream_vk_icd.@0@.json'.format(host_machine.cpu()), + output : 'gfxstream_vk_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -71,7 +72,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/imagination/vulkan/meson.build b/src/imagination/vulkan/meson.build index 245cd94f1..dfc3479d0 100644 --- a/src/imagination/vulkan/meson.build +++ b/src/imagination/vulkan/meson.build @@ -141,12 +141,13 @@ icd_file_name = libname_prefix + 'vulkan_powervr_mesa.' + libname_suffix powervr_mesa_icd = custom_target( 'powervr_mesa_icd', input : [vk_icd_gen, vk_api_xml], - output : 'powervr_mesa_icd.@0@.json'.format(host_machine.cpu()), + output : 'powervr_mesa_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -163,7 +164,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/intel/vulkan/meson.build b/src/intel/vulkan/meson.build index 4963298ae..e8101300d 100644 --- a/src/intel/vulkan/meson.build +++ b/src/intel/vulkan/meson.build @@ -51,12 +51,13 @@ icd_file_name = libname_prefix + 'vulkan_intel.' + libname_suffix intel_icd = custom_target( 'intel_icd', input : [vk_icd_gen, vk_api_xml], - output : 'intel_icd.@0@.json'.format(host_machine.cpu()), + output : 'intel_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -74,7 +75,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/intel/vulkan_hasvk/meson.build b/src/intel/vulkan_hasvk/meson.build index ed5ac7463..ea1763429 100644 --- a/src/intel/vulkan_hasvk/meson.build +++ b/src/intel/vulkan_hasvk/meson.build @@ -21,12 +21,13 @@ icd_file_name = libname_prefix + 'vulkan_intel_hasvk.' + libname_suffix intel_hasvk_icd = custom_target( 'intel_hasvk_icd', input : [vk_icd_gen, vk_api_xml], - output : 'intel_hasvk_icd.@0@.json'.format(host_machine.cpu()), + output : 'intel_hasvk_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -44,7 +45,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.3', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/microsoft/vulkan/meson.build b/src/microsoft/vulkan/meson.build index 0349d2ddc..99239a3e9 100644 --- a/src/microsoft/vulkan/meson.build +++ b/src/microsoft/vulkan/meson.build @@ -80,7 +80,8 @@ icd_command = [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] @@ -88,7 +89,8 @@ icd_dev_command = [ prog_python, '@INPUT0@', '--api-version', '1.1', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', join_paths(meson.current_build_dir(), icd_file_name), + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ] @@ -100,7 +102,7 @@ endif dzn_icd = custom_target( 'dzn_icd', input : [vk_icd_gen, vk_api_xml], - output : 'dzn_icd.@0@.json'.format(host_machine.cpu()), + output : 'dzn_icd.' + vulkan_manifest_suffix, command : icd_command, build_by_default : true, install_dir : with_vulkan_icd_dir, diff --git a/src/nouveau/vulkan/meson.build b/src/nouveau/vulkan/meson.build index bf6e2f7f7..e5f951b84 100644 --- a/src/nouveau/vulkan/meson.build +++ b/src/nouveau/vulkan/meson.build @@ -166,12 +166,13 @@ icd_file_name = libname_prefix + 'vulkan_nouveau.' + libname_suffix nouveau_icd = custom_target( 'nouveau_icd', input : [vk_icd_gen, vk_api_xml], - output : 'nouveau_icd.@0@.json'.format(host_machine.cpu()), + output : 'nouveau_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -189,7 +190,8 @@ custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/panfrost/vulkan/meson.build b/src/panfrost/vulkan/meson.build index 0f224db24..e8ca0510d 100644 --- a/src/panfrost/vulkan/meson.build +++ b/src/panfrost/vulkan/meson.build @@ -241,12 +241,13 @@ icd_file_name = libname_prefix + 'vulkan_panfrost.' + libname_suffix panfrost_icd = custom_target( 'panfrost_icd', input : [vk_icd_gen, vk_api_xml], - output : 'panfrost_icd.@0@.json'.format(host_machine.cpu()), + output : 'panfrost_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -264,7 +265,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/virtio/vulkan/meson.build b/src/virtio/vulkan/meson.build index e41faf685..2ad2b6ff1 100644 --- a/src/virtio/vulkan/meson.build +++ b/src/virtio/vulkan/meson.build @@ -20,12 +20,13 @@ icd_file_name = libname_prefix + 'vulkan_virtio.' + libname_suffix virtio_icd = custom_target( 'virtio_icd', input : [vk_icd_gen, vk_api_xml], - output : 'virtio_icd.@0@.json'.format(host_machine.cpu()), + output : 'virtio_icd.' + vulkan_manifest_suffix, command : [ prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', vulkan_icd_lib_path / icd_file_name, + '--icd-lib-path', vulkan_icd_lib_path, + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, @@ -43,7 +44,8 @@ _dev_icd = custom_target( prog_python, '@INPUT0@', '--api-version', '1.4', '--xml', '@INPUT1@', '--sizeof-pointer', sizeof_pointer, - '--lib-path', meson.current_build_dir() / icd_file_name, + '--icd-lib-path', meson.current_build_dir(), + '--icd-filename', icd_file_name, '--out', '@OUTPUT@', ], build_by_default : true, diff --git a/src/vulkan/util/vk_icd_gen.py b/src/vulkan/util/vk_icd_gen.py index 7760dd6b0..d5fb0f07d 100644 --- a/src/vulkan/util/vk_icd_gen.py +++ b/src/vulkan/util/vk_icd_gen.py @@ -22,6 +22,7 @@ import argparse import json +import os import re import xml.etree.ElementTree as et @@ -48,8 +49,10 @@ if __name__ == '__main__': help='Vulkan registry XML for patch version') parser.add_argument('--sizeof-pointer', required=False, type=int, help='sizeof(void*) on the host cpu') - parser.add_argument('--lib-path', required=True, - help='Path to installed library') + parser.add_argument('--icd-lib-path', required=True, + help='Folder of icd lib_path to installed library') + parser.add_argument('--icd-filename', required=True, + help='Filename of icd lib_path to installed library') parser.add_argument('--out', required=False, help='Output json file.') parser.add_argument('--use-backslash', action='store_true', @@ -63,7 +66,12 @@ if __name__ == '__main__': else: re.match(r'\d+\.\d+\.\d+', version) - lib_path = args.lib_path + lib_path = args.icd_filename + if args.out and len(os.path.basename(args.out).split('.')) == 3: + # The output filename is the form of '${icd_id}.${host_machine.cpu()}.json', + # that means vulkan_manifest_per_architecture are true. + lib_path = args.icd_lib_path + '/' + args.icd_filename + if args.use_backslash: lib_path = lib_path.replace('/', '\\')